package com.humngyang.com.hmy.controller;


import com.humngyang.com.hmy.entity.Goods;
import com.humngyang.com.hmy.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/GoodsController")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    @RequestMapping("/getAllGoods")
    public Map<String,Object> getAllGoods(@RequestBody Map<String,Object> prames){
        Map<String, Object> allGoods = goodsService.getAllGoods(prames);
        return allGoods;
    }

    @RequestMapping("/addgoods")
    public Map<String,Object> addgoods(@RequestBody Goods goods){
        Map<String,Object> re = new HashMap<>();
        goodsService.addgoods(goods);
        re.put("flag",1);
        return re;
    }
    
    /**
     * Author : hmy
     * @date 2020/3/3 12:30
     * describution :根据id删除商品
     **/
    @RequestMapping("/delateByGoodId")
    public Map<String,Object> delateByGoodId(@RequestBody Goods goods){
        Map<String,Object> re = new HashMap<>();
        goodsService.delateByGoodId(goods.getId());
        re.put("flag",1);
        return re;
    }


}
